@extends('admin.layouts.admin')
@section('content')
    <div class="card">
        <div class="card-body">
            <ul class="nav nav-tabs nav-overflow header-tabs">
                <li class="nav-item">
                    <a href="{{route('admin.category.index')}}" class="nav-link pb-3 active">
                        栏目列表
                    </a>
                </li>
                <li class="nav-item">
                    <a href="{{route('admin.category.create')}}" class="nav-link pb-3">
                        发表栏目
                    </a>
                </li>
            </ul>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>分类名称</th>
                    <th>分类描述</th>
                    <th>等级</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($categorys as $v)
                    <tr>
                        <td scope="row">{{$v['id']}}</td>
                        <td>{!! $v['_title'] !!}</td>
                        <td>
                            {{$v['description']}}
                        </td>
                        <td>{{$v['_level']}}</td>
                        <td class="text-right">
                            <div class="btn-group btn-group-sm" role="group" aria-label="First group">
                                <a href="{{route('admin.category.edit',$v['id'])}}"
                                   class="btn btn-light btn-sm">编辑</a>
                                <form id="delete" action="{{route('admin.category.destroy',$v['id'])}}" method="post">
                                    @csrf
                                    @method('DELETE')
            <button type="button" class="btn btn-sm btn-dark" onclick="del()">删除</button>
                                </form>
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>

    </div>

@endsection
@push('js')
    <script>
        function del() {
            if (confirm('确定要删除吗?')) {
             $("#delete").submit()
            } else {
                return false;
            }
        }
    </script>
@endpush

